#ifndef PID_FLIB_H
#define	PID_FLIB_H

#include "stdint.h"

#ifdef	__cplusplus
extern "C" {
#endif	
	
typedef struct
{
    float        GAIN; 
    float        TI;  
}PI_CON_Type;

typedef struct
{
    float        GAIN;  
    float        TI;    
    float        TD;    
} PID_CON_Type;

typedef struct
{
    float        PFAC_SP; 
    float        GAIN; 
    float        TI; 
    float        TD; 
    float        D_F; 
    float        CON_ZONE; 
    unsigned char        CONZ_ON; 
} PAR_SAVE_Type;

typedef struct {
    float    PV_IN;          
    int      intPV_PER;      
    float    DISV;      
    unsigned char    INT_HPOS; 
    unsigned char    INT_HNEG; 
    unsigned char    SELECT;      
    float    PV;    
    float    LMN;   
    int    intLMN_PER;      
    unsigned char    QPULSE; 
    unsigned char    QLMN_HLM; 
    unsigned char    QLMN_LLM; 
    unsigned char    QC_ACT;  
    
    float    CYCLE;   
    
    float    CYCLE_P;  
    
    float    SP_INT;   
    float    MAN;   
    unsigned char    COM_RST; 
    unsigned char    MAN_ON;   
    float    DEADB_W;   
    float    I_ITLVAL;  
    float    LMN_HLM;   
    float    LMN_LLM;   
    float    PV_FAC;    
    float    PV_OFFS;   
    float    LMN_FAC;   
    float    LMN_OFFS;  
    float    PER_TM;   
    float    P_B_TM;   
    float    TUN_DLMN;  
    
    unsigned char    PER_MODE;  
    unsigned char    PVPER_ON; 
    unsigned char    I_ITL_ON; 
    unsigned char    PULSE_ON; 
    unsigned char    TUN_KEEP; 
    float    ER;   
    float    LMN_P;   
    float    LMN_I;   
    float    LMN_D;   
    int    intPHASE;      
    int    intSTATUS_H;      
    int    intSTATUS_D;      
    unsigned char    QTUN_RUN; 
    PI_CON_Type PI_CON;
    PID_CON_Type PID_CON;
    PAR_SAVE_Type PAR_SAVE; 
    float    PFAC_SP;   
    float    GAIN;   
    float    TI;  
    float    TD;  
    float    D_F;   
    float    CON_ZONE; 
    unsigned char    CONZ_ON; 
    unsigned char    TUN_ON; 
    
    unsigned char    TUN_ST; 
    
    unsigned char    UNDO_PAR; 
    unsigned char    SAVE_PAR; 
    unsigned char    LOAD_PID; 
    
    unsigned char    PID_ON;  
    float    GAIN_P;   
    float    TU;   
    float    TA;   
    
    float    KIG;   
    float    N_PTN;   
    float    TM_LAG_P;   
    float    T_P_INF;   
    float    P_INF;   
    float    LMN0;   
    float    PV0;   
    float    PVDT0;   
    float    PVDT;   
    float    PVDT_MAX;   
    float    NOI_PVDT;   
    float    NOISE_PV;   
    int    intFIL_CYC;      
    int    intPOI_CMAX;      
    int    intPOI_CYCL;      
    int    intSctFil;
    float    srPv;
    float    srNoise;
    float    srPvdt2;
    float    srPvdtMax2;
    float    srNoise2;
    float    srPvOld2;
    int    intSiStatus;
    int    intSiSpDir;
    float    srTime;
    float    sPvOld;
    float    sSpOld;
    float    srPvMin;
    float    srPVsim;
    float    srEffDlmn;
    float    sInvAlt;   
    float    sIanteilAlt;  
    float    sRestInt;   
    float    sRestDif;   
    float    sRueck;
    float    sLmn;     
    float   spassPTm;
    float    sCycTmPass;
    float    sPTm;
    float    srOptLmn;
    unsigned char    sbOptLmn;
    unsigned char    sbConzOn;
    unsigned char   sbSpChange;  
    unsigned char    sbReOpt;
    float    sLmnHlmOld;
    float   sLmnLlmOld;
    float    srDiffSp;
    long int    siTime;
    long int    siCycle;
    long int    siCycleP;
    int    intSiPulsFil;
    float    srPulsPv;
    float    srDPvdt;
    float    srDPvdt2;
    float    sNpInf;
    float    sCycleM;
    float    sGf11_30;
    float    sGf12_30;
    float    sGf21_30;
    float    sGf22_30;
    float    sPv0Sim_30;
    float    srPVsim3_30;
    float    srPVsim2_30;
    float    srPVsim1_30;
    float    srDelPvsim_30;
    float    sGf11_20;
    float    sGf12_20;
    float    sGf21_20;
    float    sGf22_20;
    float    sPv0Sim_20;
    float    srPVsim2_20;
    float    srPVsim1_20;
    float    srDelPvsim_20;
    float    sGf11_15;
    float    sGf12_15;
    float    sGf21_15;
    float    sGf22_15;
    float    sPv0Sim_15;
    float    srPVsim2_15;
    float    srPVsim1_15;
    float    srDelPvsim_15;
    
    long int    tTime;
    long int    iTime;
    float    rDiff;
    
    float    dLmn;	  
    
    unsigned char    bLMNnew;
    unsigned char    bPulse;
    unsigned char    bConzOn;	 
    float    rSeek;
    float    rPvDelt;
    float   rPvFil;
    float   rPV0;
    float    rPvdtOri;
    float    rPVsigned;
    float    rSpDelt;	 
    float   tw_durch_tu;
    float    gf;
    float    koeff;
    float    rCycle;	
    
    float    rDeltaI;	
    float    rVal;
    float    rPvNew2;
    float    rNoiPvdt;
    float    rPvdtMax0;
    
    float    rPvdt;
    float    rPvdt2;
    float    rPvdt3;	 
    int    intFilCyc;	 
    int    intVal;
    float    rT1sim;	 
    float    rT2sim;	 
    float    rKsim;
    float    rSumHp;
    float    rSumLp;
    float    rHp;
    float    rLp;
    float    rNptn;	
    float    rNptnHl;	
    float    rNptnLl;	
    int      chk_err_cnt;
    
} SemPidType;
    
void SemPidInit(SemPidType *pid);
void SemPid(SemPidType *pid);

#ifdef	__cplusplus
}
#endif

#endif	
